package com.sztz.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sztz.vo.UserExcelVo;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 用户信息表
 * @author yzy
 * @date 2023/3/22 19:36
 */
@TableName("t_user")
@Data
@EqualsAndHashCode(callSuper = true)
public class User extends BaseEntity {
    /**
     * 用户ID
     */
    @TableId(type = IdType.AUTO)
    private int id;
    /**
     * 用户代码
     */
    private String userCode;
    /**
     * 用户登录账号
     */
    private String userName;
    /**
     * 用户登录密码
     */
    private String password;
    /**
     * 用户状态
     */
    private Integer status;
    /**
     * 性别
     */
    private Integer sex;
    /**
     * 联系电话
     */
    private String  phone;
    /**
     * 角色列表
     */
    @TableField(exist = false)
    private List<Role> roles;
    public User(){

    }
    public User(String userName){
        this.userName = userName;
    }
    /**
     * 实体对象转为ExcelVo对象
     * @author yzy
     * @date 2022/08/01 16:43
     */
    public UserExcelVo convertToExcelVo(){
        UserExcelVo userExcelVo = new UserExcelVo();
        userExcelVo.setUserCode(this.getUserCode());
        userExcelVo.setName(this.getUserName());
        userExcelVo.setSex(this.getSex());
        userExcelVo.setPhone(this.getPhone());
        return userExcelVo;
    }

}
